package org.aphasia4j.dao.core;

import java.util.List;

import org.aphasia4j.model.Model;

/**
 * Interface description as basis for inherited dao interfaces.
 * 
 * @author hillger.t
 */
public interface BaseDao<T extends Model> {

  /**
   * Persists the given object inside the datastore.
   * 
   * @param obj The object to persist.
   */
  public void persist(T obj);
  
  /**
   * Deletes the given object from a datastore.
   * 
   * @param obj The object to delete.
   */
  public void remove(T obj);
  
  /**
   * Deletes an entity with the given identifier.
   * 
   * @param id The identifier key value.
   */
  public void remove(long id);
  
  /**
   * Cleans all object of this generic class with all the dependencies.
   */
  public void clean();
  
  /**
   * Cleans all object of the given class with all it's dependencies.
   * 
   * @param clazz The class which points to a mapped table.
   */
  public void clean(Class<T> clazz);
  
  /**
   * Selects an entity from the datastore by it's given identifier value.
   * 
   * @param <T> The entity type.
   * @param id  The identifier value.
   * @return    The entity.
   */
  public T get(long id);

  /**
   * Select a list of all entities from the underlying datastore.
   */
  public List<T> findAll();

  /**
   * Select a list of all entities from the underlying datastore associated with the given class.
   * 
   * @param clazz The class pointing to a approbriate table.
   */
  public <E> List<E> findAll(Class<E> clazz);
}